package com.ruoyi.web.controller.system;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.IDashboardService;

/**
 * 仪表盘统计数据
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/dashboard")
public class DashboardController extends BaseController
{
    @Autowired
    private IDashboardService dashboardService;
    @Autowired
    private ISysConfigService configService;

    /**
     * 获取所有模块的汇总数据
     */
    @GetMapping("/summary")
    public AjaxResult getSummaryData()
    {
        Map<String, Object> data = dashboardService.getSummaryData();
        return success(data);
    }

    /**
     * 获取资格审查模块的统计数据
     */
    @GetMapping("/qualification/stats")
    public AjaxResult getQualificationStats()
    {
        Map<String, Object> data = dashboardService.getQualificationStats();
        return success(data);
    }

    /**
     * 获取体能测评模块的统计数据
     */
    @GetMapping("/physical/stats")
    public AjaxResult getPhysicalStats()
    {
        Map<String, Object> data = dashboardService.getPhysicalStats();
        return success(data);
    }

    /**
     * 获取体检面试模块的统计数据
     */
    @GetMapping("/medical/stats")
    public AjaxResult getMedicalStats()
    {
        Map<String, Object> data = dashboardService.getMedicalStats();
        return success(data);
    }

    /**
     * 获取职位选择模块的统计数据
     */
    @GetMapping("/position/stats")
    public AjaxResult getPositionStats()
    {
        Map<String, Object> data = dashboardService.getPositionStats();
        return success(data);
    }
    
    /**
     * 系统初始化，清空所有模块数据
     */
    @PostMapping("/init")
    public AjaxResult initSystem()
    {
        return toAjax(dashboardService.initSystem());
    }


    /**
     * 系统计算日期
     */
    @GetMapping("/findRiQi")
    public AjaxResult findRiQi()
    {

        String nian = configService.selectConfigByKey("sys.jxs.nian");
        String yue = configService.selectConfigByKey("sys.jxs.yue");
        String ri = configService.selectConfigByKey("sys.jxs.ri");
        Map<String, Object> result = new HashMap<>();

        result.put("nian",nian);
        result.put("yue",yue);
        result.put("ri",ri);

        return success(result);
    }
} 